package com.javafactroy.kunlong.bip.icp.message.dxp.app;

import com.javafactroy.kunlong.bip.icp.message.dxp.base.DxpMsgResp;
import com.javafactroy.kunlong.bip.icp.message.base.iface.IMessage;
import lombok.Data;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

@Data
public class HandshakeMessageResp extends DxpMsgResp implements IMessage {
    String appid;
    int ilen;

    public HandshakeMessageResp(String appid){
        this.appid=appid;
    }
    @Override
    public byte[] encode() {

        byte[] b =  encoder.encode(appid.getBytes()).getBytes();

        ilen = 4 + b.length;
        ByteBuffer byteBuffer = ByteBuffer.allocate(ilen);
        byteBuffer.order(ByteOrder.BIG_ENDIAN);
        byteBuffer.putInt(ilen);
        byteBuffer.put(b);
        return byteBuffer.array();
    }

    @Override
    public void decode(byte[] buf) {

    }

    @Override
    public void check() {

    }

    @Override
    public String getMessageId() {
        return "";
    }
}
